<?php

/*
|--------------------------------------------------------------------------
| API 路由定义
|--------------------------------------------------------------------------
|
| 在这里定义API路由，为了方便阅读，建议使用apiResource定义资源路由组，并对一类
| 业务路由进行分组管理！
|
*/

/**
 * 用户注册认证路由组
 */
Route::group(['prefix' => 'auth', 'namespace' => 'Auth'], function () {
	Route::post('login', 'LoginController@login');
	Route::post('logout', 'LoginController@logout')->middleware('auth:user');
	Route::post('register', 'RegisterController@register');
	Route::post('registerable', 'RegisterController@registerable');
	Route::post('password', 'ResetPasswordController@password');
});

/**
 * 系统公用服务
 */
Route::group(['prefix' => 'common', 'namespace' => 'Common'], function () {
	Route::get('companies', 'PublicController@companies');
	Route::post('sendCode', 'MessageController@sendCode');
	Route::get('getCompany','ConditionController@getCompany');
    Route::get('getProject','ConditionController@getProject');
    Route::get('modules','PublicController@modules');
});

/**
 * 用户账户
 */
Route::group(['prefix' => 'account', 'namespace' => 'Account', 'middleware' => 'auth:user,admin'], function () {
	Route::get('personal', 'PersonalController@profile');
	Route::post('modify/avatar', 'PersonalController@modifyAvatar');
	Route::post('modify/password', 'PersonalController@modifyPassword');
	Route::post('modify/personal', 'PersonalController@modifyProfile');
	Route::post('modify/identification', 'PersonalController@modifyIdentification');
	Route::get('schedule', 'PersonalController@schedule');
	Route::post('signin', 'PersonalController@signin');
	Route::post('joinCompany', 'PersonalController@joinCompany');
	Route::get('joinStatus', 'PersonalController@joinStatus');
	Route::post('inspection', 'PersonalController@inspection');
	Route::post('station', 'PersonalController@station');
	Route::post('bind/registration/id', 'PersonalController@bindRegistrationID');
});

/**
 * 管理员账户
 */
Route::group(['middleware' => 'auth:user'], function () {
	Route::apiResource('company', 'CompanyController');
	Route::get('company/{company}/modules', 'CompanyController@modules');
	Route::post('company/{company}/syncModules', 'CompanyController@syncModules');
	Route::apiResource('department', 'DepartmentController');
	Route::apiResource('position', 'PositionController');
	Route::apiResource('banner', 'BannerController');
	Route::post('banner/upload', 'BannerController@upload');
	Route::post('project/attach/staff', 'ProjectController@attach');
	Route::post('project/detach/staff', 'ProjectController@detach');
	Route::apiResource('project', 'ProjectController');
	Route::get('user/exclude', 'UserController@staffByProject');
	Route::get('user/unapproved', 'UserController@unapproved');
	Route::get('user/turnover', 'UserController@turnover');
	Route::get('user/distribution/age', 'UserController@ageDistribution');
	Route::post('user/vetting', 'UserController@vetting');
	Route::post('user/batch/vetting', 'UserController@batchVetting');
	Route::post('user/bind/project', 'UserController@bindProject');
	Route::post('user/permission','UserController@user_permission');
    Route::get('user/permission/index','UserController@user_permission_index');
    Route::get('user/permission/{user}','UserController@user_permission_detail');
    Route::delete('user/permission/{user}','UserController@user_permission_delete');
    Route::get('user/position','UserController@user_permission_position');
    Route::get('user/user','UserController@user_permission_user');
    Route::get('user/getUserByProject','UserController@getUserByProject');
    Route::post('user/project','UserController@user_permission_project');
    Route::apiResource('user', 'UserController');
	Route::apiResource('article', 'ArticlesController');
    Route::post('article/upload', 'ArticlesController@upload');
    Route::get('articleProjectCount/{article}', 'ArticlesController@projectCount');
    Route::get('articleProjectCountDetail/{article}/{project}', 'ArticlesController@projectCountDetail');
    Route::get('attendance/export', 'AttendanceController@export');
    Route::get('attendance/report/day', 'AttendanceController@reportOfDay');
    Route::get('attendance/report/month', 'AttendanceController@reportOfMonth');
	Route::get('attendance/detail/day', 'AttendanceController@detailOfDay');
	Route::get('attendance/detail/month', 'AttendanceController@detailOfMonth');
	Route::get('attendance/summary/month', 'AttendanceController@summaryOfMonth');
	Route::get('attendance/validity/year', 'AttendanceController@validityOfYear');
	Route::apiResource('appeal', 'AppealController');
    Route::apiResource('attendance', 'AttendanceController');
	Route::apiResource('genre', 'GenreController');
	Route::get('schedule/day', 'ScheduleController@day');
	Route::get('schedule/genre', 'ScheduleController@scheduleOfGenre');
	Route::get('schedule/unschedule', 'ScheduleController@unschedule');
	Route::get('schedule/times', 'ScheduleController@times');
	Route::apiResource('schedule', 'ScheduleController');
	Route::put('consociation/updates','ConsociationController@updates');
    Route::get('consociation/company','ConsociationController@company');
    Route::apiResource('consociation','ConsociationController');
    Route::post('conference/{conference}/upload','ConferenceController@upload');
    Route::apiResource('conference','ConferenceController');
	Route::get('demand/day', 'DemandController@day');
	Route::get('demand/days', 'DemandController@days');
	Route::post('demand/modify', 'DemandController@modify');
	Route::delete('demand/destroy', 'DemandController@destroy');
	Route::get('demand/times', 'DemandController@times');
	Route::get('demand', 'DemandController@index');
	Route::post('demand', 'DemandController@store');
    Route::apiResource('announcement', 'AnnouncementController');
	Route::get('inspection/report', 'InspectionController@projectDimensionalityReports');
	Route::get('inspection/report/staff', 'InspectionController@staffDimensionalityReports');
	Route::get('inspection/report/circle', 'InspectionController@circleDimensionalityReports');
	Route::get('inspection/report/circle/details', 'InspectionController@circleDetails');
	Route::post('inspection/assign', 'InspectionController@assign');
	Route::get('inspection/assignment', 'InspectionController@assignment');
	Route::get('inspection/assignment/details', 'InspectionController@assignmentDetails');
    Route::apiResource('inspection', 'InspectionController');
    /**
     * 巡检管理路由
     */
    Route::group(['namespace' => 'Inspection'], function () {
        Route::apiResource('line', 'LineController');
		Route::post('circle/sync', 'CircleController@syncNodes');
		Route::apiResource('circle', 'CircleController');
		Route::post('node/{node}', 'NodeController@update');
        Route::apiResource('node', 'NodeController')->except('update');
    });
	/**
	 * 报岗岗位
	 */
    Route::post('station/schedule', 'StationController@schedule');
    Route::get('station/schedules', 'StationController@schedules');
    Route::get('station/timings', 'StationController@timings');
    Route::post('station/timings/modify', 'StationController@modifySchedule');
    Route::get('station/report', 'StationController@projectDimensionalityReports');
    Route::get('station/report/station', 'StationController@stationDimensionalityReports');
    Route::get('station/report/station/times', 'StationController@timeDimensionalityReports');
    Route::get('station/report/station/{report}', 'StationController@details');
	Route::apiResource('station', 'StationController');
	Route::delete('station/timings/destroy', 'TimingController@destroy');
	Route::apiResource('holiday', 'HolidayController');
});
/**
 * 系统
 */
Route::group(['prefix' => 'system', 'namespace' => 'System', 'middleware' => 'auth:user,admin|guest'], function () {
	Route::apiResource('module', 'ModuleController');
	Route::apiResource('position', 'PositionController');
	Route::apiResource('permission', 'PermissionController');
	Route::post('/upload', 'UploadController@upload');
	Route::get('setting/register', 'SettingController@register');
	Route::post('setting/register', 'SettingController@updateRegister');
	Route::get('setting/attendance', 'SettingController@attendance');
	Route::post('setting/attendance', 'SettingController@updateAttendance');
	Route::get('setting/infrastructure', 'InfrastructureController@index');
	Route::post('setting/infrastructure', 'InfrastructureController@update');
});

/**
 * 平台端路由
 */
Route::group(['prefix' => 'platform', 'namespace' => 'Platform', 'middleware' => 'auth:admin'], function () {
	Route::get('company', 'CompanyController@all');
	Route::get('company/unapproved', 'CompanyController@unapproved');
	Route::get('company/{company}', 'CompanyController@details');
	Route::delete('company/{company}', 'CompanyController@destroy');
	Route::post('company/{company}/vetting', 'CompanyController@vetting');
	Route::post('company/vetting/batch', 'CompanyController@batchVetting');
	Route::get('user', 'UserController@report');
	Route::get('project', 'ProjectController@report');
	Route::apiResource('admin', 'AdminController');
});

Route::get('test', 'TestController@index');
